package top.tsyz.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.tsyz.entity.Rol;
import top.tsyz.service.IRolService;

import java.util.List;

/**
 * RolController控制器
 */
@RestController
@RequestMapping("/api/roles")
@Api(tags = "Rol管理接口")
public class RolController {

    @Autowired
    private IRolService irolservice;

    @GetMapping("/list")
    @ApiOperation("获取所有Rol")
    public List<Rol> list() {
        return irolservice.list();
    }

    @GetMapping("/{id}")
    @ApiOperation("根据ID获取Rol")
    public Rol getById(@PathVariable Long id) {
        return irolservice.getById(id);
    }

    @PostMapping
    @ApiOperation("新增Rol")
    public boolean save(@RequestBody Rol rol) {
        return irolservice.save(rol);
    }

    @PutMapping
    @ApiOperation("更新Rol")
    public boolean update(@RequestBody Rol rol) {
        return irolservice.updateById(rol);
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除Rol")
    public boolean delete(@PathVariable Long id) {
        return irolservice.removeById(id);
    }
}
